/**
 * Test
 * @Author ace.ch
 * @Date 2018/4/11 15:42
 */
class Test {
    static getDescription(list?: any[]) {
        if (!list) return;

        function append_number(n) {
            return GameRules.resultText(n);
        }

        function append_list(list) {
            return GameRules.resultText(list[0]) + list[1];
        }


        let desc: string = "";
        let item;
        let extend;
        for (let i: number = 0; i < list.length; i++) {
            item = list[i];

            if (typeof item == "number") {
                desc += append_number(item);
            }
            else if (typeof item == "string") {
                desc += item;
            }
            else if (typeof item[1] == 'string') {
                desc += append_list(item);
            }
            else {
                desc += append_number(item[0]);
                desc += "(";

                extend = item[1];
                for (let j: number = 0; j < extend.length; j++) {
                    if (typeof extend[j] == "number") {
                        desc += append_number(extend[j]);
                    }
                    else if (typeof extend[j] == "string") {
                        desc += extend[j];
                    }
                    else if (typeof extend[j][1] == 'string') {
                        desc += append_list(extend[j]);
                    }

                    //补空位
                    if (j != extend.length - 1) desc += " ";
                }

                desc += ")";
            }

            if (i != list.length - 1) desc += " ";
        }

        return desc;
    }
}